global class PageUtils {

global static PageReference redirect(String url){
PageReference pageRef = new PageReference(url);
pageRef.setRedirect(true);
return pageRef;
}
global static String param(String param){
        return get(param);
    }
    
    global static String param(String param, String value){
        return put(param,value);
    }
    
global static String getParameter(String param){
return get(param);
}

global static String setParameter(String param, String value){
return put(param,value);
}

global static String get(String param){
return ApexPages.currentPage().getParameters().get(param);
}

// Returns the parameters which contains a part of the key
global static Map<String,String> getParameters(String param){
Map<String,String> parameters = new Map<String,String>();
for(String key:ApexPages.currentPage().getParameters().keySet()){
if(key.contains(param)){
parameters.put(key,ApexPages.currentPage().getParameters().get(key));
}
}
return parameters;
}

global static String put(String param, String value){
ApexPages.currentPage().getParameters().put(param,value);
return value;
}



global static String encodeVariable(String variable){
if(variable!=null){
return EncodingUtil.urlEncode(variable,'UTF-8');
} else {
return '';
}
}
}